<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="addTea">添加一个数据</button>
    <ul>
      <li v-for="item,index in teachers" :key="item.id">
        <h2>我的名字是{{item.name}}</h2>
        <p>我的爱好是{{item.hobby}}</p>
      </li>
    </ul>
  </div>
  <script>
    Vue.config.productionTip = false;

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          teachers: [
            { id: 1, name: "余维海", hobby: "金城会所" },
            { id: 2, name: "陈伟", hobby: "888号为您服务" },
            { id: 3, name: "老李", hobby: "学习讲课" },
          ],
        };
      },
      methods: {
        addTea() {
          const newTea = { id: 4, name: "婉丽", hobby: "逛街" };
          this.teachers.unshift(newTea);
        },
      },
    });
  </script>
</body>

</html>